#!/usr/bin/perl -w
#
# Copyright(c) Plink Limited 2010. All rights reserved.
#
# $Header:$
#
# $Log:$
# 
# Author:      Jeremy Banks
#
# Description: A channel
#

#----------------------------------------------------------------------
# External Modules
#----------------------------------------------------------------------

package XMLTV::Channel;

use strict;

#---------------------------------------------------------------------------
# Constructor
#---------------------------------------------------------------------------

sub new
{
   my $class = shift;
   my $self = bless {}, $class;

   eval "\$self->{_$_} = undef" for qw/id name code icon adjust longest_show_period virtual_channel source/;
   $self->{_cookies} = [];

   return $self;
}

#---------------------------------------------------------------------------
# Create a channel node
#---------------------------------------------------------------------------

sub create_channel_node
{
   my ($self, $doc) = @_;
}

# Setters and getters

#---------------------------------------------------------------------------
# Setter/getter for id
#---------------------------------------------------------------------------

sub id
{
   my ($self, $value) = @_;
   $self->{_id} = $value if $value;
   return $self->{_id};
}

#---------------------------------------------------------------------------
# Setter/getter for name
#---------------------------------------------------------------------------

sub name
{
   my ($self, $value) = @_;
   $self->{_name} = $value if $value;
   return $self->{_name};
}

#---------------------------------------------------------------------------
# Setter/getter for code
#---------------------------------------------------------------------------

sub code
{
   my ($self, $value) = @_;
   $self->{_code} = $value if $value;
   return $self->{_code};
}

#---------------------------------------------------------------------------
# Setter/getter for icon
#---------------------------------------------------------------------------

sub icon
{
   my ($self, $value) = @_;
   $self->{_icon} = $value if $value;
   return $self->{_icon};
}

#---------------------------------------------------------------------------
# Setter/getter for virtual_channel
#---------------------------------------------------------------------------

sub virtual_channel
{
   my ($self, $value) = @_;
   $self->{_virtual_channel} = $value if $value;
   return $self->{_virtual_channel};
}

#---------------------------------------------------------------------------
# Setter/getter for source
#---------------------------------------------------------------------------

sub source
{
   my ($self, $value) = @_;
   $self->{_source} = $value if $value;
   return $self->{_source};
}

#---------------------------------------------------------------------------
# Setter/getter for adjust
#---------------------------------------------------------------------------

sub adjust
{
   my ($self, $value) = @_;
   $self->{_adjust} = $value if $value;
   return $self->{_adjust};
}

#---------------------------------------------------------------------------
# Getter for cookies
#---------------------------------------------------------------------------

sub cookies
{
   my $self = shift;
   return $self->{_cookies};
}

#---------------------------------------------------------------------------
# Setter/getter for longest show period
#---------------------------------------------------------------------------

sub longest_show_period
{
   my ($self, $value) = @_;
   $self->{_longest_show_period} = $value if $value;
   return $self->{_longest_show_period};
}

#----------------------------------------------------------------------
# String representation
#----------------------------------------------------------------------

sub to_string
{
   my $self = shift;

   my $str = "XMLTV::Channel:\n";
   $str .= "\t$_: " . ($self->{"_$_"} || "undef") . "\n"
       for qw/id name code icon adjust longest_show_period virtual_channel source/;
   return $str;
}

1;
